package com.realtest.baidu;

/**
 * @Author: Ethan Yankang
 * @Program: Interview
 * @Date: 2024-08-22 19:36
 **/
public class xiaohong16 {
    static int n0=2;
    static int m0=3;
    static int[] f0=new int[]{2,2};
    static int[][] range0=new int[][]{{1,2},{1,2},{2,2}};

    public static void main(String[] args) {
        System.out.println(lastSolution(n0, f0, range0, m0));
    }

    private static int lastSolution(int n, int[] f, int[][] range, int m) {
//        直接利用愤怒值递减即可，减为0说明不干了
        int last=0;
        for (int i = 0; i < m; i++) {
//            每一行都要处理
//            每次修改让[num2[0],num[1]]的人让愤怒值加1
            int l=range[i][0];
            int r=range[i][1];
            for (int j = l-1; j < r; j++) {
               if (f[j]--<0) return last;
            }last++;
        }
        return last;
    }
}
